// pages/login/login.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isChoose: false,
    array: ['男', '女'],
    index: 0,
    cage: '',
    cname: '',
    csex: '男',
    pwd: '',
  
  },



  getpwd: function (e) {
    this.data.pwd = e.detail.value
  },

  getcname: function (e) {
    this.data.cname = e.detail.value;
  },

  getcage: function (e) {
    this.data.cage = e.detail.value;
  },



  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value);
    this.data.csex = this.data.array[e.detail.value]
    this.setData({
      index: e.detail.value
    })
  },

  bindPickerChange1: function (e) {
    this.data.ifc = this.data.array1[e.detail.value]
    this.setData({
      index1: e.detail.value
    })
  },

  formSubmit: function (e) {
    var that = this;
    var form = e.detail.value;
    if (form.name == '' || form.tel == '' || form.pwd == '' || form.email=='') {
      wx.showToast({
        title: '信息不全',
      })
      return false;
    }
    wx.request({
      url: app.globalData.headurl + '/Customer/updateCustomer',
      data: {
        Name: form.name,
        email: form.email,
        tel: form.tel,
        openid: app.globalData.openid,
        pwd: form.pwd,
        id: app.globalData.customer.id,
        Slogen:form.slogen,
        Age:form.age,
        Sex:form.sex
      },
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded' // POST请求
      },
      success(re) {
        app.globalData.customer = re.data;
        wx.showToast({
          title: '修改成功',
        })
        wx.navigateBack({})

      }
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    console.log("customer:"+JSON.stringify(app.globalData.customer))
    that.setData({
      customer:app.globalData.customer
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})